Learning Sinatra by Sudeep Agarwal & Manoj Sehrawat

Learning Sinatra by Sudeep Agarwal & Manoj Sehrawat

Author:Sudeep Agarwal & Manoj Sehrawat [Agarwal, Sudeep]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-04-27T04:00:00+00:00


This block checks whether the currently logged in user can edit the permissions on the given list or not. If yes, it deletes all the old permissions and sets the new permissions. We will design our HTML form in such a way that it submits the list id and new permission (private, shared, or public) and an array of users with their permission levels (read_only or read_write) if the list is made shared. If the list is made private, the array of users will have the currently logged user and level as read_write.

Let's go through this code line by line:

Line 55: This gets the record of the currently logged in user.

Line 56: This gets the record of the list.

Line 57: This sets the value of the can_change_permission variable to true.

Lines 59-66: This checks whether the user has permissions to edit the list. If not, it changes the value of the can_change_permission variable to false.

This is the same as we did in the edit_list route.

Lines 68-87: If can_change_permission is true, it updates the list's permission value and deletes all the existing permissions. It also sets the permissions for all the users with the permission level as specified if the list is made private or shared. Otherwise, it shows the error page.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Deep Learning with Python by François Chollet(12607)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7797)
Grails in Action by Glen Smith Peter Ledbrook(7707)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6430)
Kotlin in Action by Dmitry Jemerov(5077)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3886)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3339)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(3095)
Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos(2878)
The Art Of Deception by Kevin Mitnick(2617)
Drugs Unlimited by Mike Power(2476)
The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution by Walter Isaacson(2395)
A Blueprint for Production-Ready Web Applications: Leverage industry best practices to create complete web apps with Python, TypeScript, and AWS by Dr. Philip Jones(2319)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2317)
Writing for the Web: Creating Compelling Web Content Using Words, Pictures and Sound (Eva Spring's Library) by Lynda Felder(2270)
SEO 2018: Learn search engine optimization with smart internet marketing strategies by Adam Clarke(2197)
JavaScript by Example by S Dani Akash(2144)
DarkMarket by Misha Glenny(2088)
Wireless Hacking 101 by Karina Astudillo(2084)
Hands-On Cybersecurity with Blockchain by Rajneesh Gupta(2031)